<?php

/**
 * SocialEngine
 *
 * @category   Application_Extensions
 * @package    Sitereview
 * @copyright  Copyright 2012-2013 BigStep Technologies Pvt. Ltd.
 * @license    http://www.socialengineaddons.com/license/
 * @version    $Id: Global.php 6590 2013-04-01 00:00:00Z SocialEngineAddOns $
 * @author     SocialEngineAddOns
 */
class Sitereview_Form_Admin_Settings_Global extends Engine_Form {

  public function init() {

    $this->setTitle('Global Settings')
            ->setDescription('These settings affect all members in your community.')
            ->setName('review_global');

    $settings = Engine_Api::_()->getApi('settings', 'core');

    $this->addElement('Text', 'sitereview_lsettings', array(
        'label' => 'Enter License key For Reviews & Ratings Plugin',
        'description' => "Please enter your license key that was provided to you when you purchased this plugin. If you do not know your license key, please contact the Support Team of SocialEngineAddOns from the Support section of your Account Area.(Key Format: XXXXXX-XXXXXX-XXXXXX )",
        'value' => $settings->getSetting('sitereview.lsettings'),
    ));

    $isSitereviewlistingtypeEnabled = Engine_Api::_()->getDbtable('modules', 'core')->isModuleEnabled('sitereviewlistingtype');
    if( !empty($isSitereviewlistingtypeEnabled) ) {
      $this->addElement('Text', 'sitereviewlistingtype_lsettings', array(
          'label' => 'Enter License key For Reviews & Ratings - Multiple Listing Types Extension',
          'description' => "Please enter your license key that was provided to you when you purchased this plugin. If you do not know your license key, please contact the Support Team of SocialEngineAddOns from the Support section of your Account Area.(Key Format: XXXXXX-XXXXXX-XXXXXX )",
          'value' => $settings->getSetting('sitereviewlistingtype.lsettings'),
      ));
    }

    if (APPLICATION_ENV == 'production') {
      $this->addElement('Checkbox', 'environment_mode', array(
          'label' => 'Your community is currently in "Production Mode". We recommend that you momentarily switch your site to "Development Mode" so that the CSS of this plugin renders fine as soon as the plugin is installed. After completely installing this plugin and visiting few pages of your site, you may again change the System Mode back to "Production Mode" from the Admin Panel Home. (In Production Mode, caching prevents CSS of new plugins to be rendered immediately after installation.)',
          'description' => 'System Mode',
          'value' => 1,
      ));
    } else {
      $this->addElement('Hidden', 'environment_mode', array('order' => 990, 'value' => 0));
    }

    $this->addElement('Button', 'submit_lsetting', array(
        'label' => 'Activate Your Plugin Now',
        'type' => 'submit',
        'ignore' => true
    ));

    $this->addElement('Radio', 'sitereview_network', array(
        'label' => 'Browse by Networks',
        'description' => "Do you want to show listings according to viewer's network if he has selected any? (If set to no, all the listings will be shown.)",
        'multiOptions' => array(
            1 => 'Yes',
            0 => 'No'
        ),
        'onclick' => 'showDefaultNetwork(this.value)',
        'value' => $settings->getSetting('sitereview.network', 0),
    ));

    $this->addElement('Radio', 'sitereview_default_show', array(
        'label' => 'Set Only My Networks as Default in search',
        'description' => 'Do you want to set "Only My Networks" option as default for Show field in the search form widget? (This widget appears on the listings browse and home pages, and enables users to search and filter listings.)',
        'multiOptions' => array(
            1 => 'Yes',
            0 => 'No'
        ),
        'onclick' => 'showDefaultNetworkType(this.value)',
        'value' => $settings->getSetting('sitereview.default.show', 0),
    ));

    $this->addElement('Radio', 'sitereview_networks_type', array(
        'label' => 'Network selection for Listings',
        'description' => "You have chosen that viewers should only see Listings of their network(s). How should a Listing's network(s) be decided?",
        'multiOptions' => array(
            0 => "Listing Owner's network(s) [If selected, only members belonging to listing owner's network(s) will see the Listings.]",
            1 => "Selected Networks [If selected, listing owner will be able to choose the networks of which members will be able to see their Listing.]"
        ),
        'value' => Engine_Api::_()->getApi('settings', 'core')->getSetting('sitereview.networks.type', 0),
    ));

    $this->addElement('Radio', 'sitereview_proximity_search_kilometer', array(
        'label' => 'Proximity Search',
        'description' => 'Do you want proximity search to be enabled for listings? (Proximity search will enable users to search for listings within a certain distance from a location. Proximity search will work only if you enable the \'Location Field\' from \'Manage Listing Type\' section of this plugin.)',
        'multiOptions' => array(
            0 => 'Miles',
            1 => 'Kilometers'
        ),
        'value' => $settings->getSetting('sitereview.proximity.search.kilometer', 0),
    ));

    $this->addElement('Text', 'sitereview_map_city', array(
        'label' => 'Centre Location for Map at Listings Home and Browse Listings',
        'description' => 'Enter the location which you want to be shown at centre of the map which is shown on Listings Home and Browse Listings when Map View is chosen to view Listings.(To show the whole world on the map, enter the word "World" below.)',
        'required' => true,
        'value' => $settings->getSetting('sitereview.map.city', "World"),
    ));

    $this->addElement('Select', 'sitereview_map_zoom', array(
        'label' => "Default Zoom Level for Map at Listings Home and Browse Listings",
        'description' => 'Select the default zoom level for the map which is shown on Listings Home and Browse Listings when Map View is chosen to view Listings. (Note that as higher zoom level you will select, the more number of surrounding cities/locations you will be able to see.)',
        'multiOptions' => array(
            '1' => "1",
            "2" => "2",
            "4" => "4",
            "6" => "6",
            "8" => "8",
            "10" => "10",
            "12" => "12",
            "14" => "14",
            "16" => "16"
        ),
        'value' => $settings->getSetting('sitereview.map.zoom', 1),
    ));

    $this->addElement('Radio', 'sitereview_map_sponsored', array(
        'label' => 'Sponsored Listings with a Bouncing Animation',
        'description' => 'Do you want the sponsored listings to be shown with a bouncing animation in the Map?',
        'multiOptions' => array(
            1 => 'Yes',
            0 => 'No'
        ),
        'value' => $settings->getSetting('sitereview.map.sponsored', 1),
    ));

    $this->addElement('Radio', 'sitereview_fs_markers', array(
        'label' => 'Featured, Sponsored and New Markers',
        'description' => 'On Listings Home, Browse Listings and My Listings how do you want a Listing to be indicated as Featured, Sponsored and New ? (Note: Listing having "New" marker will be indicated by labels only.)',
        'multiOptions' => array(
            1 => 'Using Labels (See FAQ for customizing the labels)',
            0 => 'Using Icons',
        ),
        'value' => Engine_Api::_()->getApi('settings', 'core')->getSetting('sitereview.fs.markers', 1),
    ));

    $this->addElement('Radio', 'sitereview_tinymceditor', array(
        'label' => 'Tinymce Editor',
        'description' => 'Allow TinyMCE editor for discussion message of Listings.',
        'multiOptions' => array(
            1 => 'Yes',
            0 => 'No'
        ),
        'value' => $settings->getSetting('sitereview.tinymceditor', 1),
    ));

    $this->addElement('Radio', 'sitereview_editorprofile', array(
        'label' => 'Editor Profile Link',
        'description' => 'Where do you want to redirect users, when they click on Editors’ photo, name and view profile links?',
        'multiOptions' => array(
            1 => 'On Editor Profile',
            0 => 'On Member Profile',
        ),
        'value' => $settings->getSetting('sitereview.editorprofile', 1),
    ));

    $view = Zend_Registry::isRegistered('Zend_View') ? Zend_Registry::get('Zend_View') : null;
    $localeObject = Zend_Registry::get('Locale');
    $currencyCode = Engine_Api::_()->getApi('settings', 'core')->getSetting('payment.currency', 'USD');
    $currencyName = Zend_Locale_Data::getContent($localeObject, 'nametocurrency', $currencyCode);
    $this->addElement('Dummy', 'sitereview_currency', array(
        'label' => 'Currency',
        'description' => "<b>" . $currencyName . "</b> <br class='clear' /> <a href='" . $view->url(array('module' => 'payment', 'controller' => 'settings'), 'admin_default', true) . "' target='_blank'>" . Zend_Registry::get('Zend_Translate')->_('edit currency') . "</a>",
    ));
    $this->getElement('sitereview_currency')->getDecorator('Description')->setOptions(array('placement', 'APPEND', 'escape' => false));

    if (Engine_Api::_()->getDbtable('modules', 'core')->isModuleEnabled('sitereviewlistingtype')) {
      $this->addElement('Radio', 'sitereview_showcategories_menu', array(
          'label' => 'Listing Types Navigation Bar',
          'description' => "Do you want to display Listing Types Navigation Bar above the 'Navigation Tabs' widget as configured by you from the Layout Editor? (If you select 'Yes', then all the listings types on your site will be displayed in this bar. Categories of listing types will be displayed on mouseover.)",
          'multiOptions' => array(
              1 => 'Yes',
              0 => 'No'
          ),
          'value' => $settings->getSetting('sitereview.showcategories.menu', 1),
      ));
    }

    $social_share_default_code = '<div class="addthis_toolbox addthis_default_style ">
		<a class="addthis_button_preferred_1"></a>
		<a class="addthis_button_preferred_2"></a>
		<a class="addthis_button_preferred_3"></a>
		<a class="addthis_button_preferred_4"></a>
		<a class="addthis_button_preferred_5"></a>
		<a class="addthis_button_compact"></a>
		<a class="addthis_counter addthis_bubble_style"></a>
		</div>
		<script type="text/javascript">
		var addthis_config = {
							services_compact: "facebook, twitter, linkedin, google, digg, more",
							services_exclude: "print, email"
		}
		</script>
		<script type="text/javascript" src="https://s7.addthis.com/js/250/addthis_widget.js"></script>';

    $this->addElement('Hidden', 'is_remove_note', array('value' => 0, 'order' => 999));
    $this->addElement('Textarea', 'sitereview_code_share', array(
        'label' => 'Social Share Widget Code',
        'description' => "Personalize the code for social sharing buttons by adding your own code generated from: <a href='http://www.addthis.com/' target='_blank'>http://www.addthis.com/</a>. If you do not want to show these buttons, then you can simply empty this field.",
        'value' => $settings->getSetting('sitereview.code.share', $social_share_default_code),
    ));
    $this->sitereview_code_share->addDecorator('Description', array('placement' => 'PREPEND', 'class' => 'description', 'escape' => false));

    $this->addElement('Button', 'save', array(
        'label' => 'Save Changes',
        'type' => 'submit',
        'ignore' => true
    ));
  }

}
